package com.dqv5.k8s.userinfo.service.impl;

import com.dqv5.k8s.userinfo.repository.UserRepository;
import com.dqv5.k8s.userinfo.entity.UserInfo;
import com.dqv5.k8s.userinfo.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author duqian
 * @date 2020/9/25
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserRepository userRepository;

    @Override
    public List<UserInfo> queryAll() {
        return userRepository.findAll();
    }

    @Override
    public UserInfo queryById(Long id) {
        return userRepository.findById(id).orElseThrow(RuntimeException::new);
    }

    @Override
    public void insert(UserInfo userInfo) {
        userRepository.save(userInfo);
    }

    @Override
    public void update(UserInfo userInfo) {
        userRepository.save(userInfo);
    }

    @Override
    public void delete(Long id) {
        userRepository.deleteById(id);
    }
}
